package service

import (
	"context"

	v1 "kra/api/helloworld/v1"
	"kra/internal/biz"
	"kra/internal/data"
)

// GreeterService is a greeter service.
type GreeterService struct {
	v1.UnimplementedGreeterServer

	uc          *biz.GreeterUsecase
	UserUseCase *data.UserUseCase
}

// NewGreeterService new a greeter service.
func NewGreeterService(uc *biz.GreeterUsecase, UserUseCase *data.UserUseCase) *GreeterService {
	return &GreeterService{uc: uc, UserUseCase: UserUseCase}
}

// SayHello implements helloworld.GreeterServer.
func (s *GreeterService) SayHello(ctx context.Context, in *v1.HelloRequest) (*v1.HelloReply, error) {
	// g, err := s.uc.CreateGreeter(ctx, &biz.Greeter{Hello: in.Name})
	// if err != nil {
	// 	return nil, err
	// }
	println(in.Name)

	// n := "张三"
	// age := 2
	// r, err := s.repo.User.FindByNameAndAge(n, age)
	// if err != nil {
	// 	return nil, err
	// }
	// fmt.Printf(r.Name)
	// logic.Query(ctx)
	s.UserUseCase.Query(ctx)
	return &v1.HelloReply{Message: "Hello " + in.Name}, nil
}
